<!DOCTYPE html>


<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="component/layui/css/layui.css" />
    <link rel="stylesheet" href="admin/css/pearMenu.css" />
    <link rel="stylesheet" href="admin/css/pearTab.css" />
    <link rel="stylesheet" href="admin/css/pearTheme.css" />
    <link rel="stylesheet" href="admin/css/pearLoad.css" />
    <link rel="stylesheet" href="admin/css/pearFrame.css" />
    <link rel="stylesheet" href="admin/css/pearAdmin.css" />
    <link rel="stylesheet" href="admin/css/pearNotice.css" />
    <link rel="stylesheet" href="admin/css/pearSocial.css" />
    <title>福田智慧物业</title>
    <style id="pearone-bg-color"></style>
    <style>
        .layui-nav-fixed {
            position: fixed !important;
            width: 170px !important;
            min-width: 10% !important;
            left: 234px !important;
            top: 60px !important;
        }

        .useritem {
            font-size: 14px;
            margin-left: 70%;
        }
    </style>
</head>

<body class="layui-layout-body  pear-admin">
    <!-- 布局框架 -->
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <ul class="layui-nav layui-layout-left" id="navItem">
                <li class="layui-nav-item" id="systemManage">
                    <a class="layui-icon " href="/ftwgypt/sys-manage/user"> 系统管理 </a>
                </li>
                <li class="layui-nav-item">
                    <a class="layui-icon " href="/ftwgypt/index"> 应用 </a>
                </li>

                <li class="layui-nav-item" id="dataLayer">
                    <a class="layui-icon" href="javascript:void(0)">数据治理</a>
                </li>
                <li class="layui-nav-item" id="setionData">
                    <a class="layui-icon" href="javascript:void(0)">辅助决策</a>
                </li>
                <li class="layui-nav-item itemactive" id="MapAdmin">
                    <a class="layui-icon" href="javascript:void(0)">地图后台</a>
                </li>
                <li class="layui-nav-item " id="adminUrl">
                    <a class="layui-icon" href="javascript:void(0)" >一张图</a>
                </li>

            </ul>

            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item ">
                    <a class="layui-icon layui-icon-username" href="javascript:;"><label
                            id="loginName">系统管理员</label></a>
                    <dl class="layui-nav-child layui-nav-fixed useritem">
                        <dd><a href="javascript:void(0)">个人信息</a></dd>
                        <dd><a href="javascript:void(0)" id="editPwd">修改密码</a></dd>
                        <dd><a href="javascript:void(0)" id="exit">退出登录</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-cyan">
            <div id="HeadLogo" style="font-size: 20px;"> 智慧福田物管系统</div>
            <div class="controlItem collaspe layui-nav-item">
                <a class="layui-icon layui-icon-shrink-right" href="#"></a>
                <span class="kongzhitaiFont">控制台</span>
            </div>
            <div class="layui-side-scroll" style="height: 81.3%">
                <div id="sideMenu"></div>
            </div>
        </div>
        <div class="layui-body">
            <div id="content"></div>
        </div>
    </div>

    <!-- 移动端 遮盖层 -->
    <div class="pear-cover"></div>

    <!-- 初始加载 动画-->
    <!-- <div class="preloader">
        <div class="preloader-inner"></div>
    </div> -->


    <script src="component/layui/layui.js"></script>
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });
        var ipLocation = location.origin;
        if (window.sessionStorage.envLocation) {
            window.sessionStorage.envLocation = window.sessionStorage.envLocation
        } else {
            window.envLocation = ipLocation + '/map/admin';
            // window.envLocation = "http://192.168.101.143:9080/map/admin";
            window.sessionStorage.envLocation = window.envLocation;
        }
        layui.use(['pearAdmin', 'jquery', 'pearTab', 'pearNotice'], function () {
            var pearAdmin = layui.pearAdmin;
            var $ = layui.jquery;
            var pearTab = layui.pearTab;
            var pearNotice = layui.pearNotice;
            var config = {
                keepLoad: 1200, // 主 页 加 载 过 度 时 长 可为 false
                muiltTab: true, // 是 否 开 启 多 标 签 页 true 开启 false 关闭
                control: false, // 是 否 开 启 多 系 统 菜 单 true 开启 false 关闭
                theme: "dark-theme", // 默 认 主 题 样 式 dark-theme 默认主题 light-theme 亮主题
                index: 'view/system/user.html', // 默 认 加 载 主 页
                data: 'admin/data/menu.json', // 菜 单 数 据 加 载 地 址
                done: function () {
                    /** 框架初始化 */
                    var aa = $(document).find("a[menu-id='41']")
                    aa.parent().addClass("layui-this")

                }
            };
            pearAdmin.render(config);
            /**
             * 消 息 初 始 化
             * */
            pearNotice.render({
                elem: 'headerNotice',
                url: 'admin/data/notice.json',
                height: '200px',
                click: function (id, title) {
                    layer.msg("当前监听消息" + id + "消息标题:" + title);
                }
            })

            $("body").on("click", ".pearson", function () {
                pearTab.addTabOnlyByElem("content", {
                    id: 111,
                    title: "个人信息",
                    url: "http://www.baidu.com",
                    close: true
                })
            })
            $(document).ready(function () {
                getUserInfo();

                $("#dataLayer").click(function () {
                    window.location.href = ipLocation + "/dataplus";
                })
                $("#setionData").click(function () {
                    window.location.href = ipLocation + "/aidDecision";
                })
                $("#MapAdmin").click(function () {
                    window.location.href = ipLocation + "/admin";
                })
                $("#adminUrl").click(function () {
                    window.open(ipLocation + "/map");
                })
                //修改密码
                $("#editPwd").click(function () {
                    var storage = window.sessionStorage.getItem("dbl-user");
                    var jsonObj = JSON.parse(storage);
                    if (typeof jsonObj.content == "object") {
                        var loginName = jsonObj.content.username;
                        var userid = jsonObj.content.userId;
                        window.location.href = ipLocation + "/ftwgypt/editPassword?userId=" + userid + "&username=" + loginName;
                    } else {
                        var contentobj = JSON.parse(jsonObj.content);
                        var loginName = contentobj.username;
                        var userid = contentobj.userId
                        window.location.href = ipLocation + "/ftwgypt/editPassword?userId=" + userid + "&username=" + loginName;
                    }
                })
            });

            function clearAllcookie() {
                var date = new Date();
                date.setTime(date.getTime() - 10000);
                var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
                console.log(keys);
                if (keys) {
                    for (var i = keys.length; i--;) {
                        document.cookie = keys[i] + '=0; expire=' + date.toGMTString() + '; path=/';
                    };
                };
            };

            function exitLogin() {
                $.ajax({
                    url: '/auth/logout',
                    type: "DELETE",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (result) {
                        clearAllcookie();
                        var storage = window.sessionStorage;
                        storage.removeItem('dbl-user');
                        storage.removeItem('dbl-menus');
                        storage.removeItem('dbl-roles');
                        storage.removeItem('dbl-dict');
                        storage.removeItem('dbl-token');
                        //获取页面的url地址 pathname
                        var pathname = window.location.pathname;
                        window.sessionStorage.setItem("lastUrl", pathname);
                        if (storage.getItem("dbl-user") == null) {
                            if (window.location.hostname !== 'localhost') {
                                SettimeOut();
                            }
                        }
                    }
                })
            }
            $(document).on('click', '#exit', function () {
                exitLogin();
            });

            function getUserInfo() {
                var storage = window.sessionStorage.getItem("dbl-user");
                if (storage !== null) {
                    var jsonObj = JSON.parse(storage);
                    if (typeof jsonObj.content == "object") {
                        var loginName = jsonObj.content.realName;
                        var loginInfo = document.getElementById("loginName").innerHTML = loginName;
                    } else {
                        var contentobj = JSON.parse(jsonObj.content);
                        var loginName = contentobj.realName;
                        var loginInfo = document.getElementById("loginName").innerHTML = loginName;
                    }
                } else {
                    var pathname = window.location.pathname;
                    var storage = window.sessionStorage;
                    storage.setItem("lastUrl", pathname)
                    if (window.location.hostname !== 'localhost') {
                        SettimeOut();
                    }
                }
            }
            //进行跳转
            function SettimeOut() {
                setTimeout("location='/ftwgypt/login'", 1500);
            }
            //头部导航栏进行跳转
            $("#systemManage").click(function () {
                $(this).addClass("itemactive");
                $("#systemManage>a").css("color", "#fff");
            })
        })


    </script>
</body>

</html>
